<template>
	<view class="page-bg">
		<view class="head-box">
			<uni-search-bar radius="5" style="flex: 1;" v-model="keyword" placeholder="输入店铺名称搜索" cancelButton="none"
				@confirm="getDyPoiList" />
			<view @click="getDyPoiList" class="btn">搜索</view>
		</view>
		<view class="list-item" v-for="item,index in dataList" :key="index" @click="checkPoi(item)">
			<view class="name">{{item.poi_name}}</view>
			<view class="address">{{item.address}}</view>
		</view>
	</view>
</template>

<script>
	const app = getApp();
	export default {
		data() {
			return {
				keyword: '',
				dataList: []
			}
		},
		onLoad(e) {
			if (e.name) {
				this.keyword = e.name
				this.getDyPoiList()
			}
		},
		methods: {
			checkPoi(item) {
				uni.setStorageSync("pcikPOI", item.poi_id)
				uni.navigateBack({
					delta: 1
				})
			},
			getDyPoiList() {
				uni.showLoading({
					title: "加载中..."
				})
				uni.request({
					url: app.globalData.serviceUrl + '/UserMiniProgramController/searchDouyinPoiList',
					data: {
						city: "成都",
						keyword: this.keyword
					},
					method: 'POST',
					header: {
						'content-type': 'application/x-www-form-urlencoded'
					},
					success: res => {
						this.dataList = res.data.data
						uni.hideLoading()
					},
					complete() {
						uni.hideLoading()
					}
				});

			}
		}
	}
</script>

<style scoped lang="scss">
	.page-bg {
		background: rgba(242, 243, 248, 1);
	}

	.head-box {
		display: flex;
		align-items: center;

		.btn {
			padding: 10rpx 20rpx;
		}
	}

	.list-item {
		border-radius: 10rpx;
		margin: 20rpx;
		padding: 10rpx 20rpx;
		background-color: #fff;

		.name {
			color: #333;
		}

		.address {
			color: #666;
			margin-top: 5rpx;
		}
	}
</style>